#include "Bullet.h"

using namespace model;

Bullet::Bullet(void) : Entity()
{
	type = Bullet::BULLET;
}

Bullet::Bullet(int id, std::string image, const Point &position, int duration, double startTime)
{
	this->id = id;
	imagePath = image;
	x = position.x();
	y = position.y();
	this->duration = duration;
	this->startTime = startTime;
	type = Bullet::BULLET;
	this->exploted= false;
	this->time = 0;
}

Bullet::~Bullet(void)
{
}

Bullet::BulletType Bullet::getType(void)
{
	return type;
}

void Bullet::setType(BulletType bt)
{
	type = bt;
}

std::string Bullet::getTypeName(BulletType type)
{
	string typeName;
	if (type == LASER)
	{
		typeName = "LASER";
	}
	else if (type == MISSILE)
	{
		typeName = "MISSILE";
	}
	else if (type == BOMB)
	{
		typeName = "BULLET";
	}
	else if (type == BOMBEXPLOTED)
	{	
		typeName = "BOMB";
		}
	return typeName;
}

string Bullet::getImagePath(void)
{
	return imagePath;
}

void Bullet::setImagePath(string path)
{
	this->imagePath = path;
}

void Bullet::setDuration(int duration)
{
	this->duration = duration;
}

int Bullet::getDuration()
{
	return duration;
}

void Bullet::setStartTime(double start)
{
	this->startTime = start;
}

double Bullet::getStartTime()
{
	return startTime;
}

int Bullet::getPowerDamage(void)
{
	int damagePower = 1;
	if (type == LASER)
	{
		damagePower = 2;
	}
	else if (type == MISSILE)
	{
		damagePower = 4;
	}
	else if (type == BOMB)
		damagePower = 3;
	else if (type == BOMBEXPLOTED)
		damagePower = 2;
	return damagePower;
}

void Bullet::updatePositions(double currentTime)
{
	double deltaTime;
	deltaTime = currentTime - this->currentTime;
	if (this->type == Bullet::BOMBEXPLOTED)
	{
		this->currentTime = currentTime;
		this->directionModul = 0;
	}
	else
	{
	this->currentTime = currentTime;
	this->directionModul = BULLET_VELOCITY;
	}
	if (this->type == Bullet::BOMB)
		this->directionModul = this->getVelocity();
	this->move();
	
}

void Bullet::setShipOwner(int shipId)
{
	owner = shipId;
}
int Bullet::getShipOnwer()
{
	return owner;
}

void Bullet::setTime(int time)
{
	this->time = time;
}
void Bullet::SetExploted(bool explote)
{
	this->exploted = explote;
}
int  Bullet::getTime()
{ 
	return this->time;
}

bool   Bullet::getExploted()
{
	return this->exploted;
}